<template>
  <section v-loading="loading" class="cms-body">

    <div class="cms-list-header flex-between">
      <div>
        <el-select v-model="params.state" @change="goQuery()">
          <el-option label="状态" value=""></el-option>
          <el-option label="未处理" value="0"></el-option>
          <el-option label="已处理" value="1"></el-option>
        </el-select>
        <cms-input label="姓名" v-model="params.userName"></cms-input>
        <cms-input label="手机号码" v-model="params.mobile"></cms-input>
        <cms-input label="公司名称" v-model="params.companyName"></cms-input>
      <!--  <el-date-picker
          format="yyyy-MM-dd"
          value-format="yyyy-MM-dd"
          v-model="params.queryTime"
          type="daterange"
          align="left"
          unlink-panels
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期">
        </el-date-picker>-->
        <el-button @click="goQuery()">查询</el-button>
      </div>
    </div>

    <!-- 数据表格显示区域 -->
    <el-table :data="tableData" stripe style="width: 100%" @selection-change="checkIds">

      <el-table-column type="selection" width="65" align="center"></el-table-column>

      <el-table-column prop="id" label="ID" width="150" align="center"></el-table-column>

      <el-table-column prop="userName" label="姓名" align="center"></el-table-column>

      <el-table-column prop="mobile" label="手机号码" align="center"></el-table-column>

      <el-table-column prop="companyName" label="公司名称" align="center"></el-table-column>

      <el-table-column prop="companyAddress" label="公司所在地" align="center"></el-table-column>

      <el-table-column prop="state" label="处理状态" align="center">
        <div slot-scope="scope">
          <span v-if="scope.row.state==0">未处理</span>
          <span v-if="scope.row.state==1">已处理</span>
        </div>
      </el-table-column>

      <el-table-column prop="remark" label="备注" align="center"></el-table-column>

      <el-table-column prop="createTime" label="创建日期" align="center"></el-table-column>

      <el-table-column width="100" label="操作" align="center">
        <div slot-scope="scope">
          <cms-button type="edit" @click.native="routerLink('/advApply/update','update',scope.row.id)" v-perms="'/advApply/update'"></cms-button>
          <cms-button type="delete" @click.native="deleteBatch($api.advApplyDelete,scope.row.id)" v-perms="'/advApply/delete'"></cms-button>
        </div>
      </el-table-column>
    </el-table>

    <!-- 表格底部 -->
    <div class="cms-list-footer">
      <div class="cms-left"></div>
      <!-- cms分页组件 -->
      <cms-pagination :total="total" @change="getPages"></cms-pagination>
    </div>

  </section>
</template>
<script>
  import listMixins from '@/mixins/list'
  import axios from "axios/index";
  import {setBaseUrl} from '@/config.js'

  export default {
    mixins: [listMixins],
    data() {
      return {
        params: {//只需要业务参数
          pageNo: 1,
          pageSize: 10,
          state:'',
          userName: '',
          mobile: '',
          companyName: '',
          queryTime: '',
          startTime: '',
          endTime: ''
        }
      }
    },
    methods: {
      goQuery() {
        let queryTime = this.params.queryTime;
        if (!this.$myUtils.isNull(queryTime)) {
          for (let i in queryTime) {
            let time = queryTime[i];
            if (i == 0) {
              this.params['startTime'] = time;
            }
            if (i == 1) {
              this.params['endTime'] = time;
            }
          }
        }
        console.log(this.params);
        this.getTableData(this.params);
      },
    },
    created() {
      this.initTableData(this.$api.advApplyPageList, this.params);
    }
  };
</script>
